package editAir.buildEdit.ui.buildList
{

	import com.net.AssetData;
	import com.ui.cell.LabelSource;
	import com.ui.controls.Button;
	import com.ui.controls.ComboBox;
	import com.ui.controls.List;
	import com.ui.data.ComboBoxData;
	import com.ui.data.ListData;
	import com.ui.skin.SkinStyle;
	
	import editAir.buildEdit.BuildEditDisplay3DSprite;
	import editAir.buildEdit.BuildEditEvent;
	import editAir.buildEdit.BuildEditEventVO;
	import editAir.buildEdit.EditManage;
	
	import flash.display.DisplayObjectContainer;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	import robotleMvc.ui.SkinType;
	import robotleMvc.ui.TextUtil;
	import robotleMvc.ui.UIUtil;

	public class BuildListView extends Pan3dWindow
	{
		private var _qualityComboxBox:ComboBox;
		private var _sortComboxBox:ComboBox;
		private var _buildList:List;
		private var bulidItem:Array;
		private var butadd:Button;
		private var butdele:Button;
		private var _butSceneCanCatch:Button;
		private var butRefresh:Button;

		public function BuildListView(parent:DisplayObjectContainer, isTitleBar:Boolean=true)
		{
			super(parent, isTitleBar);
			titleName="模型列表";
			adjustWindowSize(350, 400);
			addTexts();
			addLists();
			addButs();
			addEvents();

		}
		
		private function addButs():void
		{
		     butadd= UIUtil.addButton(this,15,310,25,20,"+")
		     butdele= UIUtil.addButton(this,45,310,25,20,"-")
		     butRefresh= UIUtil.addButton(this,75,310,25,20,"R")
		     _butSceneCanCatch= UIUtil.addButton(this,120,70,70,25,"可选模型")
				 
		}
		
		private function addEvents():void
		{
			// TODO Auto Generated method stub
			butadd.addEventListener(MouseEvent.MOUSE_DOWN,butaddClik)
			butdele.addEventListener(MouseEvent.MOUSE_DOWN,butdeleClik)
			butRefresh.addEventListener(MouseEvent.MOUSE_DOWN,butRefreshClik)
			_butSceneCanCatch.addEventListener(MouseEvent.MOUSE_DOWN,_butSceneCanCatchDown)
		}
		
		protected function butRefreshClik(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			EditManage.setBuildListSource();
		}
		
		protected function _butSceneCanCatchDown(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			EditManage.notChangeOther=!EditManage.notChangeOther
			if(EditManage.notChangeOther){
				_butSceneCanCatch.htmlText="可选模型"
			}else{
				_butSceneCanCatch.htmlText="关闭可选"
			}
		}
		
		protected function butdeleClik(event:MouseEvent):void
		{
			var evtVo:BuildEditEventVO=new BuildEditEventVO;
			evtVo.eventID=BuildEditEvent.DELE_BUILD_OBJ;
			EditManage.sendEvent(evtVo); 
		}
		
		protected function butaddClik(event:MouseEvent):void
		{
			var evtVo:BuildEditEventVO=new BuildEditEventVO;
			evtVo.eventID=BuildEditEvent.ADD_BUILD_OBJ;
			EditManage.sendEvent(evtVo); 
	
		}
		public function setListSource(arr:Vector.<BuildEditDisplay3DSprite>):void
		{
		
			var tempArr:Array=new Array
			for each (var tempVo:BuildEditDisplay3DSprite in arr)
			{
				
				tempArr.push(tempVo);

			}
			
			for(var i:int=0;i<tempArr.length;i++)
			{
				if(EditManage.chooseBuildEditSprite){
					if(EditManage.chooseBuildEditSprite.id==tempArr[i].id){
						chooseId(i);
					}
				}
			}
			_buildList.model.source=tempArr;

		}
		public function chooseId(num:int):void
		{
			_buildList.selectionModel.index=num;
			_buildList.scrollSetHeightValue(num*35);
		}
		

		private function addLists():void
		{
			var data:ListData=new ListData();
			data.width=325;
			data.height=200;
			data.cell=BuildEditListCell;
			data.parent=this;
			data.hGap=5;
			data.bgAsset=UIUtil.blackKuang();
			data.cellData.upAsset=new AssetData(SkinStyle.emptySkin);
			data.cellData.height=30;
			data.cellData.overAsset=new AssetData(SkinStyle.emptySkin);
			data.cellData.disabledAsset=new AssetData(SkinStyle.emptySkin);
			data.cellData.selected_upAsset=data.cellData.selected_overAsset= UIUtil.btnDown();
				

			_buildList=new List(data);
			addChild(_buildList);
			_buildList.moveTo(10, 100);


		}


		private function addTexts():void
		{
			var titleTip:TextField=TextUtil.getTextField()
			titleTip.x=30;
			titleTip.y=75;
			titleTip.htmlText="请选择类形";
			addChild(titleTip);
		}
	}
}
